#include <iostream>
#include <ostream>
#include<vector>
using namespace std;
int huiwen(string& str)
{
    int len = str.size();
    vector<vector<int>> dp(len,vector<int>(len,0));
    for(int i = len-1;i>=0;i--)
    {
        dp[i][i] = 1;
        for(int j = i+1;j<len;j++)
        {
            if(str[i] == str[j])
            {
                dp[i][j] = dp[i+1][j-1]+2;
            }
            else {
                dp[i][j] = max(dp[i][j-1],dp[i+1][j]);
            }
        }
    }
    return len - dp[0][len-1];
}
int main() {
    string str;
    while(getline(cin,str))
    {
        cout<<huiwen(str)<<endl;
    }
}
// 64 位输出请用 printf("%lld")